package com.ruoyi.web.pojo.request.warning;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.domain.warning.WarningAddressBook;
import com.ruoyi.web.utils.BasePageQuery;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;


/**
 * 五情预警通讯录
 * @author fwx
 * @since 2024-01-31 14:08:37
 */
@Data
@ApiModel(value = "WarningAddressBook对象", description = "五情预警通讯录")
public class WarningAddressBookRequest extends BasePageQuery {

    @ApiModelProperty("联系人姓名")
    @TableField("contact_name")
    private String contactName;

    @ApiModelProperty("联系人电话")
    @TableField("contact_phone")
    private String contactPhone;

    /**
     * @desc  构建查询条件
     * @author fwx 2024/2/1 14:25
     **/
    public void bulidWrapper(QueryWrapper<WarningAddressBook> query){
        //预警等级
        if(StringUtils.isNotBlank(this.getContactName())){
            query.lambda().like(WarningAddressBook::getContactName,this.getContactName());
        }

        //因子key
        if(StringUtils.isNotBlank(this.getContactPhone())){
            query.lambda().like(WarningAddressBook::getContactPhone,this.getContactPhone());
        }

        query.lambda().orderByDesc(WarningAddressBook::getCrtTime);
    }

}
